// 基本信息表单配置文件

// 字段配置接口
export interface FieldConfig {
  key: string;
  label: string;
  type: 'input' | 'textarea' | 'select' | 'date' | 'file' | 'multifile' | 'tree-select' | 'custom-department-picker' | 'portrait-camera';
  icon: string;
  placeholder: string;
  required?: boolean;
  disabled?: boolean;
  inputType?: string;
  maxlength?: number;
  pattern?: string; // 正则表达式验证
  patternErrorMessage?: string; // 正则验证失败的错误信息
  options?: { value: any; text: string }[];
  tips?: string;
  defaultValue?: any;
  fullWidth?: boolean; // 是否占满整行
  fileConfig?: {
    mediatype?: string;
    mode?: string;
    limit?: number;
    title?: string;
    imageStyles?: any;
    maxSize?: number; // 最大文件大小(MB)
    quality?: number; // 图片质量 0-1
  };
  // 特殊字段标识
  isIdCard?: boolean; // 是否是身份证相关字段
  isVeteranRelated?: boolean; // 是否是退伍军人相关字段
  dependsOn?: string; // 依赖的字段key
  dependsOnValue?: any; // 依赖字段的值
}

// 行配置接口
export interface RowConfig {
  key: string;
  fields: FieldConfig[];
}

// 模块配置接口
export interface ModuleConfig {
  key: string;
  title: string;
  subtitle: string;
  icon: string;
  rows: RowConfig[];
}

// 表单配置接口
export interface BasicInfoFormConfig {
  modules: ModuleConfig[];
}

// 性别选项
const genderOptions = [
  { value: "男", text: "男" },
  { value: "女", text: "女" },
  { value: "其他", text: "其他" },
];

// 民族选项
const ethnicityOptions = [
  { value: "汉族", text: "汉族" },
  { value: "回族", text: "回族" },
  { value: "满族", text: "满族" },
  { value: "蒙古族", text: "蒙古族" },
  { value: "壮族", text: "壮族" },
  { value: "其他", text: "其他" },
];

// 学历选项
const educationOptions = [
  { value: "小学", text: "小学" },
  { value: "初中", text: "初中" },
  { value: "高中", text: "高中" },
  { value: "中专", text: "中专" },
  { value: "大专", text: "大专" },
  { value: "本科", text: "本科" },
  { value: "研究生", text: "研究生" },
  { value: "硕士", text: "硕士" },
  { value: "博士", text: "博士" },
  { value: "博士后", text: "博士后" },
  { value: "博士研究生", text: "博士研究生" },
  { value: "其他", text: "其他" },
];

// 婚姻状况选项
const maritalOptions = [
  { value: "未婚", text: "未婚" },
  { value: "已婚", text: "已婚" },
  { value: "离异", text: "离异" },
  { value: "丧偶", text: "丧偶" },
];

// 血型选项
const bloodTypeOptions = [
  { value: "A", text: "A" },
  { value: "B", text: "B" },
  { value: "AB", text: "AB" },
  { value: "O", text: "O" },
  { value: "其他", text: "其他" },
];

// 政治面貌选项
const politicalOptions = [
  { value: "群众", text: "群众" },
  { value: "共青团员", text: "共青团员" },
  { value: "中共党员", text: "中共党员" },
  { value: "无党派人士", text: "无党派人士" },
  { value: "其他", text: "其他" },
];

// 退伍军人选项
const veteranOptions = [
  { value: "true", text: "是" },
  { value: "false", text: "否" },
];

// 用工形式选项
const employmentTypeOptions = [
  { value: "全职", text: "全职" },
  { value: "兼职", text: "兼职" },
  { value: "实习", text: "实习" },
  { value: "外包", text: "外包" }
];

// 合同类型选项
const contractTypeOptions = [
  { value: "固定期限", text: "固定期限" },
  { value: "无固定期限", text: "无固定期限" },
  { value: "以完成一定工作任务为期限", text: "以完成一定工作任务为期限" },
  { value: "其他", text: "其他" },
];

// 专业大类选项
const majorCategoryOptions = [
  { value: "化学", text: "化学" },
  { value: "工学", text: "工学" },
  { value: "理学", text: "理学" },
  { value: "医学", text: "医学" },
  { value: "农学", text: "农学" },
  { value: "管理学", text: "管理学" },
  { value: "经济学", text: "经济学" },
  { value: "法学", text: "法学" },
  { value: "文学", text: "文学" },
  { value: "教育学", text: "教育学" },
  { value: "艺术学", text: "艺术学" },
  { value: "历史学", text: "历史学" },
  { value: "哲学", text: "哲学" },
  { value: "其他", text: "其他" },
];

// 生育状况选项
const fertilityStatusOptions = [
  { value: "未育", text: "未育" },
  { value: "一育", text: "一育" },
  { value: "二育", text: "二育" },
  { value: "三育", text: "三育" },
  { value: "四育", text: "四育" },
  { value: "四育及以上", text: "四育及以上" },
];



// 基本信息表单配置
export const basicInfoFormConfig: BasicInfoFormConfig = {
  modules: [
    // 照片上传模块
    {
      key: "photo_upload",
      title: "照片上传",
      subtitle: "请上传个人照片和身份证照片",
      icon: "heart",
      rows: [
        {
          key: "photo_row",
          fields: [
            {
              key: "PhotoId",
              label: "个人照片",
              type: "portrait-camera",
              icon: "person",
              placeholder: "请拍摄个人照片",
              required: true,
              fullWidth: true,
              tips: "请拍摄清晰的个人近身照片，AI将自动生成证件照",
              fileConfig: {
                mediatype: "image",
                mode: "grid",
                limit: 1,
                title: "请拍摄个人照片",
                maxSize: 5,
                quality: 0.8,
                imageStyles: {
                  width: 100,
                  height: 100,
                  border: { radius: "8px" },
                },
              },
            },
          ],
        },
        {
          key: "idcard_row",
          fields: [
            {
              key: "IdCardFrontPhotoId",
              label: "身份证正面",
              type: "file",
              icon: "card",
              placeholder: "请上传身份证正面照片",
              required: true,
              tips: "请确保身份证照片清晰完整，无反光、遮挡",
              isIdCard: true,
              fileConfig: {
                mediatype: "image",
                mode: "grid",
                limit: 1,
                title: "请上传身份证正面照片",
                imageStyles: {
                  width: 160,
                  height: 100,
                  border: { radius: "8px" },
                },
              },
            },
            {
              key: "IdCardBackPhotoId",
              label: "身份证反面",
              type: "file",
              icon: "card",
              placeholder: "请上传身份证反面照片",
              required: true,
              isIdCard: true,
              fileConfig: {
                mediatype: "image",
                mode: "grid",
                limit: 1,
                title: "请上传身份证反面照片",
                imageStyles: {
                  width: 160,
                  height: 100,
                  border: { radius: "8px" },
                },
              },
            },
          ],
        },
      ],
    },
    // 基本信息模块
    {
      key: "basic_info",
      title: "基本信息",
      subtitle: "姓名、性别、出生日期等基础信息",
      icon: "lianxiren",
      rows: [
        {
          key: "name_row",
          fields: [
            {
              key: "Name",
              label: "姓名",
              type: "input",
              icon: "person",
              placeholder: "请输入您的姓名",
              required: true,
            },
            {
              key: "StaffNo",
              label: "员工工号",
              type: "input",
              icon: "gear",
              placeholder: "请输入员工工号",
              required: true,
              disabled: true,
            },
          ],
        },
        {
          key: "id_row",
          fields: [
            {
              key: "IdCardNo",
              label: "身份证号",
              type: "input",
              icon: "card",
              placeholder: "根据身份证照片自动识别",
              required: true,
              maxlength: 18,
              disabled: true,
            },
            {
              key: "Gender",
              label: "性别",
              type: "select",
              icon: "person",
              placeholder: "请选择性别",
              required: true,
              disabled: true,
              options: genderOptions,
            },
          ],
        },
        {
          key: "birth_row",
          fields: [
            {
              key: "BirthDate",
              label: "出生日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择出生日期",
              required: true,
              disabled: true,
            },
            {
              key: "Age",
              label: "年龄",
              type: "input",
              icon: "gear",
              placeholder: "请输入年龄",
              inputType: "number",
              disabled: true,
            },
          ],
        },
        {
          key: "ethnic_row",
          fields: [
            {
              key: "Ethnicity",
              label: "民族",
              type: "select",
              icon: "gear",
              placeholder: "请选择民族",
              disabled: true,
              options: ethnicityOptions,
            },
            {
              key: "HighestEducation",
              label: "最高学历",
              type: "select",
              icon: "compose",
              placeholder: "请选择最高学历",
              required: true,
              options: educationOptions,
            },
          ],
        },
        {
          key: "major_row",
          fields: [
            {
              key: "MajorCategory",
              label: "专业大类",
              type: "select",
              icon: "compose",
              placeholder: "请选择专业大类",
              required: true,
              options: majorCategoryOptions,
            },
            {
              key: "MajorName",
              label: "专业名称",
              type: "input",
              icon: "compose",
              placeholder: "请输入专业名称",
              required: true,
            },
          ],
        },
        {
          key: "marital_row",
          fields: [
            {
              key: "MaritalStatus",
              label: "婚姻状况",
              type: "select",
              icon: "heart",
              placeholder: "请选择婚姻状况",
              options: maritalOptions,
            },
            {
              key: "FertilityStatus",
              label: "生育状况",
              type: "select",
              icon: "heart",
              placeholder: "请选择生育状况",
              required: true,
              options: fertilityStatusOptions,
            },
          ],
        },
        {
          key: "blood_row",
          fields: [
            {
              key: "BloodType",
              label: "血型",
              type: "select",
              icon: "heart",
              placeholder: "请选择血型",
              options: bloodTypeOptions,
            },
          ],
        },
        {
          key: "idcard_expiry_row",
          fields: [
            {
              key: "IdCardExpiryDate",
              label: "身份证有效期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择身份证有效期",
              disabled: true,
            },
          ],
        },
      ],
    },
    // 联系方式模块
    {
      key: "contact_info",
      title: "联系方式",
      subtitle: "手机号码、邮箱地址等联系信息",
      icon: "dianhua",
      rows: [
        {
          key: "contact_row",
          fields: [
            {
              key: "Phone",
              label: "联系电话",
              type: "input",
              icon: "phone",
              placeholder: "请输入联系电话",
              required: true,
              inputType: "number",
              maxlength: 11,
              pattern: "^1[3-9]\\d{9}$",
              patternErrorMessage: "请输入正确的手机号码",
            },
            {
              key: "Email",
              label: "邮箱",
              type: "input",
              icon: "email",
              placeholder: "请输入邮箱地址",
            },
          ],
        },
        {
          key: "address_row",
          fields: [
            {
              key: "HomeAddress",
              label: "家庭住址",
              type: "input",
              icon: "location",
              placeholder: "请输入家庭住址",
              fullWidth: true,
            },
          ],
        },
      ],
    },
    // 户籍信息模块
    {
      key: "household_info",
      title: "户籍信息",
      subtitle: "户口所在地、籍贯等户籍相关信息",
      icon: "dizhi",
      rows: [
        {
          key: "household_row",
          fields: [
            {
              key: "HouseholdRegistration",
              label: "户口所在地",
              type: "input",
              icon: "location",
              placeholder: "请输入户口所在地",
              disabled: true,
            },
            {
              key: "NativePlace",
              label: "籍贯",
              type: "input",
              icon: "location",
              placeholder: "请输入籍贯",
              disabled: true,
            },
          ],
        },
      ],
    },
    // 政治信息模块
    {
      key: "political_info",
      title: "政治信息",
      subtitle: "政治面貌、党员信息、档案管理等相关信息",
      icon: "xingxing",
      rows: [
        {
          key: "political_row",
          fields: [
            {
              key: "PoliticalStatus",
              label: "政治面貌",
              type: "select",
              icon: "star",
              placeholder: "请选择政治面貌",
              options: politicalOptions,
            },
            {
              key: "PartyJoinDate",
              label: "入党(团)日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择入党(团)日期",
            },
          ],
        },
        {
          key: "party_row",
          fields: [
            {
              key: "PartyBranch",
              label: "入党所在支部",
              type: "input",
              icon: "home",
              placeholder: "请输入入党所在支部",
            },
            {
              key: "ArchiveLocation",
              label: "档案所在地",
              type: "input",
              icon: "folder",
              placeholder: "请输入档案所在地",
            },
          ],
        },
        {
          key: "archive_row",
          fields: [
            {
              key: "ArchiveNo",
              label: "存档号",
              type: "input",
              icon: "gear",
              placeholder: "请输入存档号",
            },
            {
              key: "ArchiveTransferOutDate",
              label: "档案调出日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择档案调出日期",
            },
          ],
        },
        {
          key: "archive_row2",
          fields: [
            {
              key: "ArchiveTransferInDate",
              label: "档案调入日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择档案调入日期",
            },
            {
              key: "ArchiveAgeDate",
              label: "档案年龄日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择档案年龄日期",
            },
          ],
        },
        {
          key: "veteran_row",
          fields: [
            {
              key: "IsVeteran",
              label: "是否退伍军人",
              type: "select",
              icon: "star",
              placeholder: "请选择是否退伍军人",
              options: veteranOptions,
            },
          ],
        },
        {
          key: "veteran_certificate_row",
          fields: [
            {
              key: "VeteranCertificateId",
              label: "退伍证图片",
              type: "file",
              icon: "image",
              placeholder: "请上传退伍证图片",
              fullWidth: true,
              tips: "请上传清晰的退伍证照片",
              isVeteranRelated: true,
              dependsOn: "IsVeteran",
              dependsOnValue: "true",
              fileConfig: {
                mediatype: "image",
                mode: "grid",
                limit: 1,
                title: "请上传退伍证图片",
                imageStyles: {
                  width: 100,
                  height: 100,
                  border: { radius: "8px" },
                },
              },
            },
          ],
        },
      ],
    },
    // 银行信息模块
    {
      key: "bank_info",
      title: "银行信息",
      subtitle: "工资卡、奖金卡等银行账户信息",
      icon: "zhifeiji",
      rows: [
        {
          key: "salary_bank_row",
          fields: [
            {
              key: "SalaryBank",
              label: "工资卡银行",
              type: "input",
              icon: "home",
              placeholder: "请输入工资卡银行",
              disabled: true,
            },
            {
              key: "SalaryAccount",
              label: "工资卡号",
              type: "input",
              icon: "gear",
              placeholder: "请输入工资卡号",
              disabled: true,
            },
          ],
        },
        {
          key: "bonus_bank_row",
          fields: [
            {
              key: "BonusBank",
              label: "奖金卡银行",
              type: "input",
              icon: "home",
              placeholder: "请输入奖金卡银行",
              disabled: true,
            },
            {
              key: "BonusAccount",
              label: "奖金卡号",
              type: "input",
              icon: "gear",
              placeholder: "请输入奖金卡号",
              disabled: true,
            },
          ],
        },
      ],
    },
    // 工作信息模块
    {
      key: "work_info",
      title: "工作信息",
      subtitle: "人事组织、部门、岗位等工作相关信息",
      icon: "gongwenbao",
      rows: [
        {
          key: "org_row",
          fields: [
            {
              key: "OrgId",
              label: "人事组织",
              type: "select",
              icon: "home",
              placeholder: "请选择人事组织",
              required: true,
              options: [], // 动态加载
            },
            {
              key: "GroupId",
              label: "所属部门",
              type: "custom-department-picker",
              icon: "gear",
              placeholder: "请选择所属部门",
              required: true,
            },
          ],
        },
        {
          key: "position_row",
          fields: [
            {
              key: "JobPositionId",
              label: "工作岗位",
              type: "select",
              icon: "gear",
              placeholder: "请先选择所属部门",
              required: true,
              options: [], // 动态加载
            },
          ],
        },

        {
          key: "work_date_row",
          fields: [
            {
              key: "JoinWorkDate",
              label: "参加工作时间",
              type: "date",
              icon: "calendar",
              placeholder: "请选择参加工作时间",
              tips: "首次参加工作的时间",
            },
            {
              key: "WorkYears",
              label: "工龄",
              type: "input",
              icon: "gear",
              placeholder: "根据参加工作时间自动计算",
              inputType: "number",
              disabled: true,
            },
          ],
        },
        {
          key: "hire_date_row",
          fields: [
            {
              key: "HireDate",
              label: "入职日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择入职日期",
              tips: "入职本公司的时间",
            },
            {
              key: "CompanyYears",
              label: "司龄",
              type: "input",
              icon: "gear",
              placeholder: "根据入职时间自动计算",
              inputType: "number",
              disabled: true,
            },
          ],
        },
        {
          key: "confirmation_date_row",
          fields: [
            {
              key: "ConfirmationDate",
              label: "转正日期",
              type: "date",
              icon: "calendar",
              placeholder: "请选择转正日期",
            },
          ],
        },
        {
          key: "employment_row",
          fields: [
            {
              key: "EmploymentType",
              label: "用工形式",
              type: "select",
              icon: "gear",
              placeholder: "请选择用工形式",
              options: employmentTypeOptions,
            },
            {
              key: "ContractType",
              label: "劳动合同类型",
              type: "select",
              icon: "gear",
              placeholder: "请选择劳动合同类型",
              options: contractTypeOptions,
            },
          ],
        },
        {
          key: "contract_row",
          fields: [
            {
              key: "ContractNo",
              label: "合同编号",
              type: "input",
              icon: "gear",
              placeholder: "请输入合同编号",
            },
            {
              key: "ContractStartDate",
              label: "合同起始日",
              type: "date",
              icon: "calendar",
              placeholder: "请选择合同起始日",
              disabled: true,
            },
          ],
        },
        {
          key: "contract_end_row",
          fields: [
            {
              key: "ContractEndDate",
              label: "合同终止日",
              type: "date",
              icon: "calendar",
              placeholder: "请选择合同终止日",
              disabled: true,
            },
          ],
        },


      ],
    },
    // 其他信息模块
    {
      key: "other_info",
      title: "其他信息",
      subtitle: "兴趣爱好、备注等其他补充信息",
      icon: "gongwenbao",
      rows: [
        {
          key: "hobbies_row",
          fields: [
            {
              key: "Hobbies",
              label: "兴趣爱好",
              type: "textarea",
              icon: "heart",
              placeholder: "请输入兴趣爱好",
              fullWidth: true,
            },
          ],
        },
        {
          key: "remark_row",
          fields: [
            {
              key: "Remark",
              label: "备注",
              type: "textarea",
              icon: "compose",
              placeholder: "请输入备注信息",
              fullWidth: true,
            },
          ],
        },
      ],
    },
  ],
};
